package com.miyake.server;

import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.IdentityType;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;

import com.google.appengine.api.datastore.Key;
import com.google.appengine.api.datastore.KeyFactory;
import com.miyake.client.datamanage.plugin.PluginProperty;

@PersistenceCapable(identityType = IdentityType.APPLICATION)
public class DsPlugin {
	@PrimaryKey
	@Persistent(valueStrategy=IdGeneratorStrategy.IDENTITY)  
	private Key key;
	
	@Persistent
	private String url;
	
	@Persistent
	private String name;
	
	@Persistent
	private String description;

	@Persistent
	private Integer type; // 0:Analyze, 1:File Parser
	public static final int TYPE_ANALYSIS = 0;
	public static final int TYPE_FILE = 1;
	public static final int TYPE_CHART = 2;
	
	@Persistent
	private String helpUrl;
	
	@Persistent
	private String provider;
	
	@Persistent
	private String version;
	
	@Persistent
	private String license;
	
	public String getEncodedKey() {
		return KeyFactory.keyToString(key);
	}


	public String getUrl() {
		return url;
	}

	public void setUrl(String url) {
		this.url = url;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}


	public Integer getType() {
		return type;
	}


	public void setType(Integer type) {
		this.type = type;
	}
	
	
	public String getHelpUrl() {
		return helpUrl;
	}


	public void setHelpUrl(String helpUrl) {
		this.helpUrl = helpUrl;
	}


	public PluginProperty toRemoteObject() {
		PluginProperty ret = new PluginProperty();
		ret.setKey(getEncodedKey());
		ret.setDescription(this.description);
		ret.setName(name);
		ret.setUrl(url);
		ret.setHelpUrl(helpUrl);
		ret.setProvider(provider);
		ret.setVersion(version);
		ret.setLicense(license);
		return ret;
	}


	public void setProvider(String provider) {
		this.provider = provider;
	}


	public String getProvider() {
		return provider;
	}


	public void setVersion(String version) {
		this.version = version;
	}


	public String getVersion() {
		return version;
	}


	public void setLicense(String license) {
		this.license = license;
	}


	public String getLicense() {
		return license;
	}
}
